package dao;

import beans.Meaning;
import db.DBQuery;

import java.util.List;

public class MeaningDAO extends CommonDAO<Meaning> {

    public final static MeaningDAO ME = new MeaningDAO();

    @Override
    protected String tableName() {
        return new Meaning().tableName();
    }

    /**
     * 删除一个单词关联的所有meaning
     */
    public long deleteWordMeanings(long word_id) {
        String sql = "delete from " + tableName() + " where word_id = ?";
        return DBQuery.update(sql, word_id);
    }

    public List<Meaning> listWordMeanings(long word_id) {
        String sql = "select * from " + tableName() + " where word_id = ?";
        return DBQuery.query_list(Meaning.class, sql, word_id);
    }
}
